﻿
-- 检测时间
function checkActivityTime(tOpenTime)
	local nIdx = 0;
	for i = 1, #tOpenTime do
		local starHour = tonumber(tOpenTime[i][1]);
		if starHour == 0 then
			starHour = 24;
		end
		
		local endHour = tonumber(tOpenTime[i][3]);
		if endHour == 0 then
			endHour = 24;
		end
		
		if (System.isInTimeRange(starHour, tonumber(tOpenTime[i][2]), 0, endHour, tonumber(tOpenTime[i][4]), 0)) == true then
			nIdx = i;
			break;
		end
	end
	return nIdx;
end

-- 更新活动数据
function sendActivityData(sysarg, nActivityType, args)
	local netPack = DataPack.allocPacket(sysarg, LogicCmd.activitySys.sysId, LogicCmd.activitySys.sub.sUpdateActivityData)
	DataPack.writeUInt(netPack, nActivityType) -- 活动类型
	local count = #args
	DataPack.writeByte(netPack, count) -- 参数个数
	
	for i = 1, count do
		DataPack.writeInt(netPack, args[i])
	end
	DataPack.flush(netPack)
end


function exit_activity(sysarg, nActivityType)
	local netPack = DataPack.allocPacket(sysarg, LogicCmd.activitySys.sysId, LogicCmd.activitySys.sub.sExitActivity)
	DataPack.writeUInt(netPack, nActivityType);
	DataPack.flush(netPack)
end


-- 计算经验奖励
function pdExpAward(sysarg, pdAward)
	--[[
	local nExp = 0;
	local plv = Actor.getIntProperty(sysarg, PROP_CREATURE_LEVEL)
	for i, v in ipairs(pdAward) do
		if (plv >= v.minlv and plv <= v.maxlv) or (plv >= v.minlv and v.maxlv == -1) then
			nExp = v.exp;
			break;
		end
	end
	return nExp;
	]]
end